<%@ Page Language="c#" AutoEventWireup="true" MasterPageFile="~/MasterPages/Main.Master" CodeFile="BlogEntry.aspx.cs" Inherits="_BlogEntry" Title="BlogEntry" %>

<asp:Content ID="Main" ContentPlaceHolderID="body" runat="server">
	<asp:Panel ID="blogEntryDetail" Width="100%" runat="server">
		<fieldset>
			<legend>BlogEntry Detail</legend>
			<asp:GridView ID="blogEntryGrid" AllowPaging="True" AllowSorting="True" BorderColor="White"
				BorderStyle="Ridge" CellSpacing="0" CellPadding="3" BackColor="#ffffff" AutoGenerateColumns="false"
				DataSourceID="blogEntrySource" runat="server" Width="100%" EnableSortingAndPagingCallbacks="True">
				<HeaderStyle BackColor="#ffffff" HorizontalAlign="left" Font-Bold="true" />
				<AlternatingRowStyle BackColor="#CCCC99" />
				<PagerSettings Mode="NumericFirstLast" Position="Bottom" />
				<Columns>
					<asp:HyperLinkField HeaderText="ID" DataTextField="Id" SortExpression="Id" DataNavigateUrlFields="Id"
					DataNavigateUrlFormatString="~/SampleForms/BlogEntry.aspx?BlogEntryId={0}" Target="_parent" />
					<asp:BoundField HeaderText="Subject" DataField="Subject" SortExpression="Subject" />
					<asp:BoundField HeaderText="Subhead" DataField="Subhead" SortExpression="Subhead" />
					<asp:BoundField HeaderText="Body" DataField="Body" SortExpression="Body" />
					<asp:BoundField HeaderText="Views" DataField="Views" SortExpression="Views" />
					<asp:BoundField HeaderText="Points" DataField="Points" SortExpression="Points" />
					<asp:BoundField HeaderText="Votes" DataField="Votes" SortExpression="Votes" />
					<asp:BoundField HeaderText="CreateDate" DataField="CreateDate" SortExpression="CreateDate" />
				</Columns>
			</asp:GridView>		
		</fieldset>
	</asp:Panel>
    <asp:FormView ID="blogEntryView" DataSourceID="blogEntryDetailSource" DataKeyNames="Id"
	    OnModeChange="blogEntryView_ModeChanged" Width="100%" runat="server">
        <ItemTemplate>
			 <fieldset>
				<legend>BlogEntry Detail</legend>
				<ol>
				<li>
				<asp:Label ID="idLabel" Text="Id" runat="server"/>
				<asp:Label ID="id" Text='<%# Eval("Id") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="subjectLabel" Text='Subject' runat="server"/>
				<asp:Label ID="subject" Text='<%# Eval("Subject") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="subheadLabel" Text='Subhead' runat="server"/>
				<asp:Label ID="subhead" Text='<%# Eval("Subhead") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="bodyLabel" Text='Body' runat="server"/>
				<asp:Label ID="body" Text='<%# Eval("Body") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="viewsLabel" Text='Views' runat="server"/>
				<asp:Label ID="views" Text='<%# Eval("Views") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="pointsLabel" Text='Points' runat="server"/>
				<asp:Label ID="points" Text='<%# Eval("Points") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="votesLabel" Text='Votes' runat="server"/>
				<asp:Label ID="votes" Text='<%# Eval("Votes") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="createDateLabel" Text='CreateDate' runat="server"/>
				<asp:Label ID="createDate" Text='<%# Eval("CreateDate") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
			    </ol>
			 </fieldset>
			 <asp:Button ID="add" CommandName="New" Text="Add" runat="server" />
			 <asp:Button ID="edit" CommandName="Edit" Text="Edit" runat="server" />
			 <asp:Button ID="delete" CommandName="Delete" Text="Delete" runat="server" />
		</ItemTemplate>
		<InsertItemTemplate>
			 <fieldset>
				<legend>New BlogEntry Detail</legend>
				<ol>
				<li>
				<asp:Label ID="subjectLabel" Text='Subject' runat="server"/><br/>
				<asp:TextBox id="subject" Text='<%# Bind("Subject") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="subject_RequiredFieldValidator" ControlToValidate="subject" Text="*" ErrorMessage="'Subject' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="subheadLabel" Text='Subhead' runat="server"/><br/>
				<asp:TextBox id="subhead" Text='<%# Bind("Subhead") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="bodyLabel" Text='Body' runat="server"/><br/>
				<asp:TextBox id="body" Text='<%# Bind("Body") %>' TextMode="MultiLine" Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="body_RequiredFieldValidator" ControlToValidate="body" Text="*" ErrorMessage="'Body' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="viewsLabel" Text='Views' runat="server"/><br/>
				<asp:TextBox id="views" Text='<%# Bind("Views") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="views_RequiredFieldValidator" ControlToValidate="views" Text="*" ErrorMessage="'Views' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="pointsLabel" Text='Points' runat="server"/><br/>
				<asp:TextBox id="points" Text='<%# Bind("Points") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="points_RequiredFieldValidator" ControlToValidate="points" Text="*" ErrorMessage="'Points' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="votesLabel" Text='Votes' runat="server"/><br/>
				<asp:TextBox id="votes" Text='<%# Bind("Votes") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="votes_RequiredFieldValidator" ControlToValidate="votes" Text="*" ErrorMessage="'Votes' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="createDateLabel" Text='CreateDate' runat="server"/>
				<asp:TextBox id="createDate" Text='<%# Bind("CreateDate") %>' CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="createDate_RequiredFieldValidator" ControlToValidate="createDate" Text="*" ErrorMessage="'CreateDate' is required." SetFocusOnError="True" runat="server"/>
				<asp:Calendar id="createDateCal" OnSelectionChanged="createDateCal_SelectionChanged" runat="server" />
				</li>
				<!-- TODO: Implement Many to Many (BlogCategories) -->
				</ol>
			 </fieldset>
             <asp:Button ID="submit" CommandName="Insert" Text="Save" runat="server" />
        </InsertItemTemplate>
		<EditItemTemplate>
			<fieldset>
				<legend>Edit BlogEntry Detail</legend>
				<ol>
				<li>
				<asp:Label ID="idLabel" Text="Id" runat="server"/>
				<asp:Label Id="id" Text='<%# Bind("Id") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="subjectLabel" Text='Subject' runat="server"/><br/>
				<asp:TextBox id="subject" Text='<%# Bind("Subject") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="subject_RequiredFieldValidator" ControlToValidate="subject" Text="*" ErrorMessage="'Subject' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="subheadLabel" Text='Subhead' runat="server"/><br/>
				<asp:TextBox id="subhead" Text='<%# Bind("Subhead") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="bodyLabel" Text='Body' runat="server"/><br/>
				<asp:TextBox id="body" Text='<%# Bind("Body") %>' TextMode="MultiLine" Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="body_RequiredFieldValidator" ControlToValidate="body" Text="*" ErrorMessage="'Body' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="viewsLabel" Text='Views' runat="server"/><br/>
				<asp:TextBox id="views" Text='<%# Bind("Views") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="views_RequiredFieldValidator" ControlToValidate="views" Text="*" ErrorMessage="'Views' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="pointsLabel" Text='Points' runat="server"/><br/>
				<asp:TextBox id="points" Text='<%# Bind("Points") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="points_RequiredFieldValidator" ControlToValidate="points" Text="*" ErrorMessage="'Points' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="votesLabel" Text='Votes' runat="server"/><br/>
				<asp:TextBox id="votes" Text='<%# Bind("Votes") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="votes_RequiredFieldValidator" ControlToValidate="votes" Text="*" ErrorMessage="'Votes' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="createDateLabel" Text='CreateDate' runat="server"/>
				<asp:TextBox id="createDate" Text='<%# Bind("CreateDate") %>' CssClass="formText" runat="server" /><br><asp:Calendar id="createDateCal" OnSelectionChanged="createDateCal_SelectionChanged" runat="server" /><asp:RequiredFieldValidator ID="createDate_RequiredFieldValidator" ControlToValidate="createDate" Text="*" ErrorMessage="'CreateDate' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<!-- TODO: Implement Many to Many (BlogCategories) -->
				</ol>
			 </fieldset>
             <asp:Button ID="submit" CommandName="Update" Text="Save" runat="server" />
        </EditItemTemplate>
		<EmptyDataTemplate>
				<fieldset>
				<legend>BlogEntry Detail</legend>
				No Record Selected
				</fieldset>
			<asp:Button ID="add" CommandName="New" Text="Add" runat="server" />
		</EmptyDataTemplate>
    </asp:FormView>
	<asp:ObjectDataSource ID="blogEntrySource" TypeName="Blog.Net.DataAccess.DataControls.BlogEntryDataControl"
		DataObjectTypeName="Blog.Net.Business.BusinessObjects.BlogEntryBO" SelectMethod="GetAll" SelectCountMethod="GetCountOfAll"
		InsertMethod="Save" UpdateMethod="Save" MaximumRowsParameterName="maxResults" StartRowIndexParameterName="firstResult"
		SortParameterName="sortExpression" EnablePaging="True" runat="server" >
		<InsertParameters>
            <asp:Parameter Name="blogEntry" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="blogEntry" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="blogEntryDetailSource" SelectMethod="GetById" InsertMethod="Save" UpdateMethod="Save" DeleteMethod="Delete" DataObjectTypeName="Blog.Net.Business.BusinessObjects.BlogEntryBO"
        TypeName="Blog.Net.DataAccess.DataControls.BlogEntryDataControl" runat="server">
		<SelectParameters>
            <asp:QueryStringParameter Name="id" QueryStringField="BlogEntryId" Type="Int32" />
        </SelectParameters>
		<InsertParameters>
            <asp:Parameter Name="blogEntry" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="blogEntry" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </UpdateParameters>
		<DeleteParameters>
            <asp:Parameter Name="blogEntry" Type="Object" />
        </DeleteParameters>
    </asp:ObjectDataSource>
	<asp:ObjectDataSource ID="blogCategorySource" SelectMethod="GetAll" TypeName="Blog.Net.DataAccess.DataControls.BlogCategoryDataControl" runat="server"></asp:ObjectDataSource>
</asp:Content>